<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title></title>
    <script src="../js/mui.min.js"></script>
    <link href="../css/mui.min.css" rel="stylesheet"/>
    <link href="../style/fjol_style.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="../style/xol_style.css"/>
    <link href="../css/iosSelect.css" rel="stylesheet" />
    
    <script type="text/javascript" charset="utf-8">
      	mui.init();
    	
   		
    </script>
	</head>
	<style>
		.mui-input-row label~input, .mui-input-row label~select, .mui-input-row label~textarea{
			margin-right: 10px;
			width: 50%;
		}
		.mui-input-row .mui-input-clear~.mui-icon-clear, .mui-input-row .mui-input-password~.mui-icon-eye, .mui-input-row .mui-input-speech~.mui-icon-speech{
			width: 30px;
		}
	</style>
	<body>
		<header class="mui-bar mui-bar-nav newbgRed">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">发布房源</h1>
		</header>
		<div class="mui-content">
		    <div class="mui-scroll-wrapper" style="bottom: 40px; top: 40px;">
		        <div class="mui-scroll">
		            <!--这里放置真实显示的DOM内容-->
		            
		            <p class="mt10 p10" id="firstStepTitle">第一步，填写联系方式</p>
		            <div class="mui-input-group mt5">
					    <div class="mui-input-row">
					        <label>姓名</label>
					        <input type="text" id="realname" class="mui-input-clear mui-text-right" value="" placeholder="怎么称呼您？">
					    </div>
					    <div class="mui-input-row">
					        <label>手机号</label>
					        <input type="number" id="mobile" class="mui-input-clear mui-text-right" value="" placeholder="必填">
					    </div>
					</div>
					<p class="p10 mt10">请留下联系方式，我们将会在第一时间与您联系，确认报名信息</p>
					
					<div class="p10">
						<button type="button" class="mui-btn redF1394C mui-btn-block borderRadius6" id="submitIssue">下一步</button>
					</div>
		        </div>
		    </div>
		</div>
		<script src="../css/iosSelect.js"></script>
		<script src="../js/md5.js"></script>
		<script src="../js/common.util.js"></script>
		<script src="../js/base.data.util.js"></script>
		<script src="../js/network.js"></script>
		<script src="../js/xzx.open.js"></script>
		<script>
			mui('.mui-scroll-wrapper').scroll({
			deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
		});
		
		mui.plusReady(function(){
			var userInfo = common.myStorage.getItem('userInfo');
			if(userInfo){
//				console.log(userInfo);
				document.querySelector('#realname').value = userInfo.realname;
				document.querySelector('#mobile').value = userInfo.mobile;
			}
			
				var postUrl;
				var buildingId;
			var wv = plus.webview.currentWebview();
			var _type = wv.type;
//			console.log(_type);
			switch(_type){
					case 1:		//发布房源
//					console.log(111);
					postUrl = 'fjzx/client/add-house-publish.json';
					document.querySelector('.mui-title').innerHTML = '发布房源';
					param = [{
						key:'kind',
						value:2
					},{
						key:'realname',
						value:realname
					},{
						key:'mobile',
						value:mobile
					}];
					break;
					case 2:		//租房
//					console.log(222);
					postUrl = 'fjzx/client/add-house-publish.json';
					document.querySelector('.mui-title').innerHTML = '发布出租房源';
					param = [{
						key:'kind',
						value:3
					},{
						key:'realname',
						value:realname
					},{
						key:'mobile',
						value:mobile
					}];
					break;
					case 3:		//房屋估价
//					console.log(333);
					postUrl = 'fjzx/client/add-house-appraisal.json';
					document.querySelector('.mui-title').innerHTML = '房源估价';
					break;
					case 4:		//新楼盘 团购报名
					document.querySelector('#firstStepTitle').classList.add('mui-hidden');
					postUrl = 'fjzx/common/building-buy-reg.json';
					document.querySelector('.mui-title').innerHTML = '团购报名';
					document.querySelector('#submitIssue').innerHTML = '提交报名';
					buildingId = wv.buildingId;
					param = [{
						key:'buildingId',
						value:buildingId
					},{
						key:'realname',
						value:realname
					},{
						key:'mobile',
						value:mobile
					}];
					break;
				}
			document.querySelector('#submitIssue').addEventListener('tap',function(){
				var realname = document.querySelector('#realname').value;//姓名
				var mobile = document.querySelector('#mobile').value;//手机号
				
				var param;
				if(_type==4){
					param = [{
						key:'buildingId',
						value:buildingId
					},{
						key:'realname',
						value:realname
					},{
						key:'mobile',
						value:mobile
					}];
				}else{
					 param = [{
						key:'realname',
						value:realname
					},{
						key:'mobile',
						value:mobile
					}];
				}
				

				if(realname==''){
					mui.alert('请留下您的真实姓名，以便我们称呼您');
					return false;
				}
				if(mobile==''){
					mui.alert('请留下您的手机号，以便我们联系您');
					return false;
				}else if(!(/^1\d{10}$/.test(mobile))){
						mui.alert('请填写正确的手机号，以便我们联系您');
						return false;
				}
					
					fjNetwork.post(postUrl,param,function(data){
//						console.log(JSON.stringify(data));
						if(_type!=4){
							openWindowWithPage('fj_house_issue_sub',{
								type:_type
							});
						}else{
							mui.toast(data.msg);
							var curr = plus.webview.getWebviewById('newHouse_detail');
//							curr.reload(true);
							mui.fire(curr,'groupBuyEvent');
							mui.back();
						}
					},function(msg){
//						console.log(msg);
						mui.toast(msg);
					});
//				console.log(postUrl);
			});
			document.addEventListener('muiBack',function(event){
				var wobj = plus.webview.getWebviewById("fj_selles");
				wobj.reload(true);		//页面刷新
				mui.back();
			});
		});
		</script>
	</body>
</html>
